@echo off

echo Initializing database...

REM Set MySQL path
set MYSQL_PATH="C:\Program Files\MySQL\MySQL Server 8.0\bin\mysql"

REM Check if MySQL exists
if not exist %MYSQL_PATH% (
    echo MySQL not found, please check MySQL installation path
    pause
    exit /b 1
)

REM Execute database initialization script
echo Executing database initialization script...
echo Please enter password when prompted and press Enter

%MYSQL_PATH% -u root -p < "c:\Users\Administrator\Desktop\homework-master\init-db.sql"

if %errorlevel% equ 0 (
    echo Database initialized successfully!
    echo Database 'chat_ai_system' has been created
    echo You can now start the backend service
) else (
    echo Database initialization failed, please check error messages
    echo You can also manually execute the following commands in MySQL Command Line Client:
    echo 1. Login to MySQL: mysql -u root -p
    echo 2. After entering password, execute: source c:\Users\Administrator\Desktop\homework-master\init-db.sql
)

pause